package yja.gzw.app.fragmentview

import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.FankuiAdapter
import yja.gzw.app.adapter.FensiAdapter
import yja.gzw.app.base.BaseFragment
import yja.gzw.app.databinding.FragmentFankuiyiBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class FankuiyiFragment :BaseFragment<Mainviewmodel, FragmentFankuiyiBinding>(R.layout.fragment_fankuiyi){

    private lateinit var fabiada: FankuiAdapter
    override fun initView() {

        viewmodel.onfankuileibiaowang(UserData.token, mapOf("page" to "1","pagesize" to "10","type" to "1"))

    }

    override fun dataObservese() {
        viewmodel.onfankuileibiao.observe(this, Observer {
            if(it.code==1){

                binding.review.layoutManager=
                    LinearLayoutManager(context)
                fabiada= FankuiAdapter(requireContext(),it.data.data)

                binding.review.adapter= fabiada




            }else{
                Toast.makeText(context,it.msg, Toast.LENGTH_SHORT).show()

            }

        })


    }
}